﻿// <copyright file="DiscountTypes.cs" company="NorthCoast NERO">
//     NorthCoast NERO. All rights reserved.
// </copyright>
// <author>Eric Kociecki</author>
namespace NcnPlayerCheckIn
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// Contains a set of pre-defined DiscountType objects.
    /// </summary>
    public static class DiscountTypes
    {
        /// <summary>
        /// Gets the DiscountType for plot/event coordinators.
        /// </summary>
        public static DiscountType Coordinator
        {
            get
            {
                return CreateNewType("Coordinator", 0, false, 1);
            }
        }

        /// <summary>
        /// Gets the DiscountType for usage of a game day credit.
        /// </summary>
        public static DiscountType Credit1
        {
            get
            {
                return CreateNewType("1 Game Day Credit", Costs.GameDayCostPC, true, 2);
            }
        }

        /// <summary>
        /// Gets the DiscountType for usage of a game day credit.
        /// </summary>
        public static DiscountType Credit2
        {
            get
            {
                return CreateNewType("2 Game Day Credits", Costs.GameDayCostPC * 2, true, 14);
            }
        }

        /// <summary>
        /// Gets the DiscountType for good grades.  TODO implement a check that this is not used more than once a year.
        /// </summary>
        public static DiscountType Grades
        {
            get
            {
                return CreateNewType("Grades", 20, false, 3);
            }
        }

        /// <summary>
        /// Gets the DiscountType for a group.
        /// </summary>
        public static DiscountType Group
        {
            get
            {
                return CreateNewType("Group", 5, false, 4);
            }
        }

        /// <summary>
        /// Gets the DiscountType for merchants.
        /// </summary>
        public static DiscountType Merchant
        {
            get
            {
                return CreateNewType("Merchant", 0, true, 5);
            }
        }

        /// <summary>
        /// Gets the DiscountType for members of the military including veterans.
        /// </summary>
        public static DiscountType Military
        {
            get
            {
                return CreateNewType("Military", 5, false, 6);
            }
        }

        /// <summary>
        /// Gets the DiscountType for new players.
        /// </summary>
        public static DiscountType NewPlayer
        {
            get
            {
                return CreateNewType("New Player", Costs.EventCost, false, 7);
            }
        }

        /// <summary>
        /// Gets the DiscountType for NPCs.
        /// </summary>
        public static DiscountType NPC
        {
            get
            {
                return CreateNewType("NPC", 0, false, 8);
            }
        }

        /// <summary>
        /// Gets the DiscountType for Owners.  TODO log which chapter they're from.
        /// </summary>
        public static DiscountType Owner
        {
            get
            {
                return CreateNewType("Owner", Costs.EventCost, false, 9);
            }
        }

        /// <summary>
        /// Gets the DiscountType for plot members.
        /// </summary>
        public static DiscountType Plot
        {
            get
            {
                return CreateNewType("Plot", 0, false, 10);
            }
        }

        /// <summary>
        /// Gets the DiscountType for pre-registered players.
        /// </summary>
        public static DiscountType PreReg
        {
            get
            {
                return CreateNewType("Pre-Registered", Costs.NonPreRegPenalty, true, 11);
            }
        }

        /// <summary>
        /// Gets the DiscountType for staff members.
        /// </summary>
        public static DiscountType Staff
        {
            get
            {
                return CreateNewType("Staff", 5, false, 12);
            }
        }

        /// <summary>
        /// Gets the DiscountType for members of the tavern crew.
        /// </summary>
        public static DiscountType Tavern
        {
            get
            {
                return CreateNewType("Tavern", Costs.EventCost, false, 13);
            }
        }
        
        /// <summary>
        /// Gets a Collection of all pre-defined DiscountTypes from this class.
        /// </summary>
        public static Collection<DiscountType> AllTypes
        {
            get
            {
                Collection<DiscountType> discountTypes = new Collection<DiscountType>(new List<DiscountType>());

                discountTypes.Add(Coordinator);
                discountTypes.Add(Credit1);
                discountTypes.Add(Credit2);
                discountTypes.Add(Grades);
                discountTypes.Add(Group);
                discountTypes.Add(Merchant);
                discountTypes.Add(Military);
                discountTypes.Add(NewPlayer);
                discountTypes.Add(NPC);
                discountTypes.Add(Owner);
                discountTypes.Add(Plot);
                discountTypes.Add(PreReg);
                discountTypes.Add(Staff);
                discountTypes.Add(Tavern);

                return discountTypes;
            }
        }

        /// <summary>
        /// Creates a new DiscountType based on the given parameters and returns it.
        /// </summary>
        /// <param name="name">The value to assign to DiscountType.Name.</param>
        /// <param name="value">The value to assign to DiscountType.Value.</param>
        /// <param name="isStackable">The value to assign to DiscountType.IsStackable.</param>
        /// <param name="id">The value to assign to DiscountType.ID.</param>
        /// <returns>The newly created DiscountType.</returns>
        private static DiscountType CreateNewType(string name, double value, bool isStackable, int id)
        {
            DiscountType newType = new DiscountType();
            newType.Name = name;
            newType.Value = value;
            newType.IsStackable = isStackable;
            newType.Id = id;
            return newType;
        }
    }
}
